<template>
  <h1>El-菜单组件</h1>
  <el-menu mode="horizontal" background-color="#4F8DFE" text-color="#fff"
           active-text-color="#ffd04b" @select="handleSelect" default-active="4"><!--置菜单中 index="4" 的菜单项（"精品课"）为默认选中状态-->
    <el-menu-item index="1">首页</el-menu-item>
    <el-menu-item index="2">免费课</el-menu-item>
    <el-menu-item index="3">直播课</el-menu-item>
    <el-menu-item index="4">精品课</el-menu-item>
    <el-menu-item index="5">线上班</el-menu-item>
    <el-sub-menu index="6">
      <template #title>线下班</template>
      <el-menu-item index="6-1">JSDTN2407</el-menu-item>
      <el-menu-item index="6-2">JSDTN2408</el-menu-item>
      <el-menu-item index="6-3">JSDTN2409</el-menu-item>
    </el-sub-menu>
  </el-menu>
</template>

<script setup>
//index指的是当前选中的这个菜单项的index值 6-2
//indexPath指的是如何找到当前选中的这个菜单项,也就是菜单项路径 [6,6-2,6-2-5]
const handleSelect = (index,indexPath)=>{
  console.log(index,indexPath);
}
</script>

<style scoped>

</style>